package dancertracker;

import netP5.NetAddress;
import controlP5.*;
//import SimpleOpenNI.*;
import processing.core.*;
import oscP5.*;

public class DancerTracker extends PApplet {

	//SimpleOpenNI kinect;
	OscP5 osc;
	NetAddress remote;
	
	ControlP5 ctrl;
	ControlWindow cw;
	ControlWindowCanvas cc;
	
	boolean trackHead;
	boolean trackNeck;
	boolean trackHeart;
	boolean trackRightShoulder;
	boolean trackLeftShoulder;
	boolean trackRightElbow;
	boolean trackLeftElbow;
	boolean trackRightWrist;
	boolean trackLeftWrist;
	boolean trackLeftHip;
	boolean trackRightHip;
	boolean trackLeftKnee;
	boolean trackRightKnee;
	boolean trackLeftFoot;
	boolean trackRightFoot;
	
	
	 	
	public void setup() {
		size(640,480, P3D);
		initGui();
		//initKinect();
	}

	public void draw() {
		frame.setTitle("FPS: "+(int)frameRate);
		background(0);
		
		//kinect.update();
	}
	
	
//	void initKinect()
//	{
//		kinect = new SimpleOpenNI(this);
//		// disable mirror
//		kinect.setMirror(false);
//
//		// enable depthMap generation 
//		if(kinect.enableDepth() == false)
//		{
//			println("Can't open the depthMap, maybe the camera is not connected!"); 
//			exit();
//			return;
//		}
//
//		// enable skeleton generation for all joints
//		kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL);
//
//		// enable the scene, to get the floor
//		kinect.enableScene();
//	}
	void initOsc()
	{
		osc = new OscP5(this, 1234);
		remote = new NetAddress("127.0.0.1", 12345);
	}
	void initGui()
	{
		
		trackHead = true;
		trackNeck = true;
		trackHeart = true;
		trackRightShoulder = true;
		trackLeftShoulder = true;
		trackRightElbow = true;
		trackLeftElbow = true;
		trackRightWrist = true;
		trackLeftWrist = true;
		trackLeftHip = true;
		trackRightHip = true;
		trackLeftKnee = true;
		trackRightKnee = true;
		trackLeftFoot = true;
		trackRightFoot = true;
		
		ctrl = new ControlP5(this);
		cw = ctrl.addControlWindow("Tracked Joints", 360, 520);
		cc = new CustomCanvas();
		cc.pre();
		cw.addCanvas(cc);
		//ControlWindowCanvas cwc = new ControlWindowCanvas();
		cw.setBackground(1);
		cw.hideCoordinates();
		Toggle headToggle = ctrl.addToggle("trackHead", 180, 30, 20, 20);
		Toggle neckToggle = ctrl.addToggle("trackNeck", 180, 90, 20, 20);
		Toggle heartToggle = ctrl.addToggle("trackHeart", 180, 150, 20, 20);
		Toggle rightShoulderToggle = ctrl.addToggle("trackRightShoulder", 270, 70, 20, 20);
		Toggle leftShoulderToggle = ctrl.addToggle("trackLeftShoulder", 90, 70, 20, 20);
		Toggle rightElbowToggle = ctrl.addToggle("trackRightElbow", 270, 180, 20, 20 );
		Toggle leftElbowToggle = ctrl.addToggle("trackLeftElbow", 90, 180, 20, 20 );
		Toggle rightHipToggle = ctrl.addToggle("trackRightHip", 220, 270, 20, 20);
		Toggle leftHipToggle = ctrl.addToggle("trackLeftHip", 140, 270, 20,20 );
		Toggle rightWristToggle = ctrl.addToggle("trackRightWrist", 290, 290, 20,20);
		Toggle leftWristToggle = ctrl.addToggle("trackLeftWrist", 70, 290, 20,20);
				
		Toggle rightKneeToggle = ctrl.addToggle("trackRightKnee", 270, 370, 20,20);
		Toggle leftKneeToggle = ctrl.addToggle("trackLeftKnee", 90, 370, 20,20);
		
		Toggle rightFootTogggle = ctrl.addToggle("trackRightFoot", 270, 480, 20, 20);
		Toggle leftFootToggle = ctrl. addToggle("trackLeftFoot", 90, 480, 20,20);
		
		headToggle.setCaptionLabel("Head");
		neckToggle.setCaptionLabel("Neck");
		rightShoulderToggle.setCaptionLabel("Right Shoulder");
		leftShoulderToggle.setCaptionLabel("Left Shoulder");
		rightElbowToggle.setCaptionLabel("Right Elbow");
		leftElbowToggle.setCaptionLabel("Left Elbow");
		rightWristToggle.setCaptionLabel("Right Wrist");
		leftWristToggle.setCaptionLabel("Left Wrist");
		
		headToggle.moveTo(cw);
		neckToggle.moveTo(cw);
		heartToggle.moveTo(cw);
		rightShoulderToggle.moveTo(cw);
		leftShoulderToggle.moveTo(cw);
		rightElbowToggle.moveTo(cw);
		leftElbowToggle.moveTo(cw);
		rightHipToggle.moveTo(cw);
		leftHipToggle.moveTo(cw);
		rightWristToggle.moveTo(cw);
		leftWristToggle.moveTo(cw);
		rightKneeToggle.moveTo(cw);
		leftKneeToggle.moveTo(cw);
		rightFootTogggle.moveTo(cw);
		leftFootToggle.moveTo(cw);
		
	}
	public static void main(String _args[]) {
		PApplet.main(new String[] { dancertracker.DancerTracker.class.getName() });
	}
}
